package com.xthh._function.MyPopWindow4;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.xt.xthh.R;

import java.util.List;

/**
 * Copyright: Copyright (c) 2017-2025
 * Company:
 *
 * @author: 赵小贱
 * @date: 2017/8/23
 * describe:
 */
public class HH_SpinerAdapter4 extends BaseAdapter {



    public static interface IOnItemSelectListener {
        public void onItemClick(int pos);
    }

    private List<String> mObjects;
    private LayoutInflater mInflater;
    Context ctx;

    public HH_SpinerAdapter4(Context context, List<String> mObjects) {
        this.mObjects = mObjects;
        mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        ctx = context;
    }



    @Override
    public int getCount() {
        return mObjects.size();
    }

    @Override
    public Object getItem(int pos) {
        return mObjects.get(pos).toString();
    }

    @Override
    public long getItemId(int pos) {
        return pos;
    }

    @Override
    public View getView(int pos, View convertView, ViewGroup arg2) {
        ViewHolder viewHolder;

        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.spiner_item_layout4, null);
            viewHolder = new ViewHolder();
            viewHolder.mTextView = (TextView) convertView.findViewById(R.id.textView);
            convertView.setTag(viewHolder);

            viewHolder.view_last = convertView.findViewById(R.id.view_last);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        viewHolder.mTextView.setText(mObjects.get(pos));


        if (mObjects != null){
            if (pos == mObjects.size() - 1){
                viewHolder.view_last.setVisibility(View.GONE);
            } else {
                viewHolder.view_last.setVisibility(View.VISIBLE);
            }
        }

        return convertView;
    }

    public static class ViewHolder {
        public TextView mTextView;
        public View view_last;
    }

}